import request from '../lib/index'

interface LoginProps {
  user_name: string;
  pass_word: string;
}
interface EditProps {
  id: string;
  old_pass: string;
  pass_word: string;
}
interface UserForm {
  pageNum: number,
  pageSize: number
}
interface RegisterForm {
  user_name: string;
  pass_word: string;
}
interface DeleteUser {
  id: string
}
// 登陆
const login = (data: LoginProps) => {
  return request({
    url: '/users/login',
    method: 'post',
    data
  })
}
// 修改密码
const edit = (data: EditProps) => {
  return request({
    url: '/users/edit',
    method: 'post',
    data
  })
}
// 获取用户列表
const getUserList = (data: UserForm) => {
  return request({
    url: '/users/search',
    method: 'post',
    data
  })
}
// 新增用户
const addUser = (data: RegisterForm) => {
  return request({
    url: '/users/register',
    method: 'post',
    data
  })
}
// 删除用户
const deleteUser = (data: DeleteUser) => {
  return request({
    url: '/users/delete',
    method: 'post',
    data
  })
}
export { login, edit, getUserList, addUser, deleteUser }